package main

import (
	"apibe/learn/grpc/simple_rpc/x_pb_go"
	"context"
	"fmt"
	"google.golang.org/grpc"
	"net"
)

type server struct{}

func (s *server) SentApply(ctx context.Context, in *x_pb_go.TeamApplyReq) (*x_pb_go.Response, error) {
	fmt.Println(*in)
	return &x_pb_go.Response{Code: 0, Msg: "ok", Result: []byte("ok")}, nil
}

func main() {
	listen, err := net.Listen("tcp", ":8080")
	if err != nil {
		fmt.Printf("监听端口失败： %v \n", err.Error())
		return
	}
	// 创建grpc服务器
	s := grpc.NewServer()
	// 注册服务
	x_pb_go.RegisterTeamServer(s, &server{})
	err = s.Serve(listen)
	if err != nil {
		fmt.Printf("开启服务失败: %s \n", err)
		return
	}
}
